﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Globalization;

namespace SweetSurvey.Extentions
{
    public static class UrlExtentions
    {
        private const string FORMAT_FULL_PATH = "{0}://{1}{2}";

        public static string ActionFullPath(this UrlHelper Url, string actionName, string controllerName, object routeValues)
        {
            string path = Url.Action(actionName, controllerName, routeValues);
            Uri uri = HttpContext.Current.Request.Url;
            return string.Format(
                CultureInfo.InvariantCulture,
                FORMAT_FULL_PATH,
                uri.Scheme,
                uri.Port == 80 ? uri.Host : uri.Host + ":" + uri.Port,
                path);
        }
    }
}